package com.wyvoid.forum.dao.hibernate;

import com.wyvoid.core.persistent.hibernate.HibernateDAO;
import com.wyvoid.forum.dao.IPollVoterDAO;
import com.wyvoid.forum.domain.PollVoter;

import java.util.List;

/**
 * 投票用户信息Hibernate数据处理实现
 *
 * @author wyvoid
 * @version $Revision: 1.2 $ $Date: 2006/07/28 17:04:32 $
 * @link www.wyvoid.com
 */
public class PollVoterDAO extends HibernateDAO<PollVoter> implements IPollVoterDAO {

    /**
     * 投票用户列表
     *
     * @param pollId 投票编号
     * @return 投票信息
     */
    public List findPollVoters(int pollId) {
        String hql = "from PollVoter where pollId=?";
        return doQueryList(hql, true, pollId);
    }

    /**
     * 是否存在投票用户
     *
     * @param pollUserId 用户名
     * @param pollId   投票编号
     * @return boolean 判断结果
     */
    public boolean isExistVoter(long pollUserId, int pollId) {
        String hql="select count(*) from PollVoter where userId=? and pollId=?";
        return doQueryCount(hql,pollUserId,pollId)>0;
	}
	
}
